package routes

import (
	"github.com/gin-gonic/gin"
	"library-system/middlewares"
)

// SetupRoutes 统一注册所有路由
func SetupRoutes(router *gin.Engine) {
	// 注册无需鉴权的公共路由
	registerPublicRoutes(router)

	// 创建需要鉴权的路由组，并统一添加中间件
	privateGroup := router.Group("/")
	privateGroup.Use(middlewares.JWTAuth())
	registerPrivateRoutes(privateGroup)
}

// registerPublicRoutes 注册公开路由
func registerPublicRoutes(router *gin.Engine) {
	RegisterUserRoutes(router)
}

// registerPrivateRoutes 注册私有路由
func registerPrivateRoutes(router *gin.RouterGroup) {
	RegisterBookRoutes(router)
	RegisterBorrowRoutes(router)
}
